<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ["张三","李四","王五","赵六"];//赵六
        //           0      1      2     3      4
        //添加中间 给下标为2的那个位置添加一个文渊
        // var index = 2;
        // for(var i = arr.length - 1 ; i >= index ; i--){//
        //     arr[i+1] = arr[i]
        // }
        // arr[index] = "文渊"
        // console.log(arr);

        //往开头添加元素
        // for(var i = arr.length - 1; i >= 0 ; i--){//
        //     arr[i+1] = arr[i]
        // }
        // arr[0] = "王八"

        //末尾添加元素  arr.length
        arr[arr.length] = "王八"

        for(var i = 0 ; i < arr.length ; i++){
            console.log(arr[i]);
        }
    </script>
</body>
</html>